home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBGRX100.ARJ / DRIVERS.DOC < prev    next >
Text File  |  1992-04-13  |  17KB  |  316 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.           Abstract
  8.  
  9.           This document describes the graphics driver format used for DJGPP
  10.           and the LIBGRX graphics library. It also gives hints for creating
  11.           a driver for an unsupported display adapter. 
  12.  
  13.           Introduction
  14.  
  15.           The DJGPP graphics drivers do two things:
  16.  
  17.             (1)     Invoke  the BIOS  INT  10 routine  for  setting up  the
  18.                     desired   graphics   mode.  Different   boards  support
  19.                     different resolutions and use different mode numbers --
  20.                     that's  why different drivers  are needed for different
  21.                     boards.
  22.  
  23.             (2)     Implement page  mapping for video modes  which use more
  24.                     than  64K   of  video  memory.  This   is  again  board
  25.                     dependent.
  26.  
  27.           Old driver format
  28.  
  29.           The following C declarations describe the header of an old format
  30.           DJGPP graphics  driver.  Of course,  real  drivers are  coded  in
  31.           assembly. 
  32.  
  33.           typedef unsigned short u_short;
  34.                  typedef unsigned char  u_char;
  35.  
  36.                  struct old_driver_header {
  37.                      u_short      mode_set_routine_offset;
  38.                      u_short      paging_routine_offset;
  39.                      u_short      paging_mode_flag;                          /* 0 if no separate R/W, 1 if yes */
  40.                      u_short      default_text_width;
  41.                      u_short      default_text_height;
  42.                      u_short      default_graphics_width;
  43.                      u_short      default_graphics_height;
  44.                  };
  45.  
  46.           The mode set routine does the following:
  47.  
  48.           ;--------------------------------------------------------------------------
  49.                  ; Entry: AX=mode selection
  50.                  ;                0=80x25 text
  51.                  ;                1=default text
  52.                  ;                2=text CX cols by DX rows
  53.                  ;                3=biggest text
  54.                  ;                4=320x200 graphics
  55.                  ;                5=default graphics
  56.                  ;                6=graphics CX width by DX height
  57.                  ;                7=biggest non-interlaced graphics
  58.                  ;                8=biggest graphics
  59.                  ;         CX=width (in pixels or characters) (not always used -- depends on AX)
  60.                  ;         DX=height
  61.  
  62.  
  63.  
  64.  
  65.  
  66.                  ;
  67.                  ; NOTE: This runs in real mode, but don't mess with the segment registers.
  68.                  ;
  69.                  ; Exit:  CX=width (in pixels or characters)
  70.                  ;         DX=height
  71.                  ;--------------------------------------------------------------------------
  72.  
  73.           The paging routine does the following:
  74.  
  75.           ;--------------------------------------------------------------------------
  76.                  ; Entry: AH=read page
  77.                  ;         AL=write page
  78.                  ;
  79.                  ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  80.                  ; This code must be relocatable and may not reference any data!
  81.                  ;
  82.                  ; Exit: VGA configured.
  83.                  ;        AX,BX,CX,DX,SI,DI may be trashed
  84.                  ;--------------------------------------------------------------------------
  85.  
  86.           The old  style graphics  driver structure remained  unchanged for
  87.           the  first  16  color  drivers  developed for  LIBGRX.  The  only
  88.           difference is that the  additional 15 bits  in the third word  of
  89.           the  header were given new meanings. (The 256 color DJGPP library
  90.           only used one bit to encode the capability to map different pages
  91.           for  reading and writing.) The values of these new bitfields were
  92.           assigned  as  to  stay  compatible with  the  existing  256 color
  93.           drivers.  (I.e. the  0 value  in every  bitfield selects  the 256
  94.           color   VGA  option.)   The  definition   of  these   bits  (from
  95.           "grdriver.h"):
  96.  
  97.           #define GRD_NEW_DRIVER  0x0008             /* NEW FORMAT DRIVER IF THIS IS SET */
  98.  
  99.                  #define GRD_PAGING_MASK 0x0007             /* mask for paging modes */
  100.                  #define GRD_NO_RW         0x0000           /* standard paging, no separate R/W */
  101.                  #define GRD_RW_64K        0x0001           /* two separate 64K R/W pages */
  102.                  /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  103.                  /* THE FOLLOWING THREE OPTIONS ARE NOT SUPPORTED AT THIS TIME             */
  104.                  #define GRD_RW_32K        0x0002           /* two separate 32Kb pages */
  105.                  #define GRD_MAP_128K      0x0003           /* 128Kb memory map -- some Tridents
  106.                                                                can do it (1024x768x16 without
  107.                                                                paging!!!)
  108.                  #define GRD_MAP_EXTMEM  0x0004             /* Can be mapped extended, above 1M.
  109.                                                                Some Tseng 4000-s can do it, NO
  110.                                                                PAGING AT ALL!!!! */
  111.                  /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  112.  
  113.                  #define GRD_TYPE_MASK     0xf000           /* adapter type mask */
  114.                  #define GRD_VGA           0x0000           /* vga */
  115.                  #define GRD_EGA           0x1000           /* ega */
  116.                  #define GRD_HERC          0x2000           /* hercules */
  117.  
  118.                  #define GRD_PLANE_MASK  0x0f00             /* bitplane number mask */
  119.                  #define GRD_8_PLANES      0x0000           /* 8 planes = 256 colors */
  120.  
  121.  
  122.  
  123.  
  124.  
  125.                  #define GRD_4_PLANES      0x0100           /* 4 planes = 16 colors */
  126.                  #define GRD_1_PLANE       0x0200           /* 1 plane  = 2 colors */
  127.                  #define GRD_16_PLANES     0x0300           /* VGA with 32K colors */
  128.                  #define GRD_8_X_PLANES  0x0400             /* VGA in mode X w/ 256 colors */
  129.  
  130.                  #define GRD_MEM_MASK      0x00f0           /* memory size mask */
  131.                  #define GRD_64K           0x0010           /* 64K display memory */
  132.                  #define GRD_128K          0x0020           /* 128K display memory */
  133.                  #define GRD_256K          0x0030           /* 256K display memory */
  134.                  #define GRD_512K          0x0040           /* 512K display memory */
  135.                  #define GRD_1024K         0x0050           /* 1MB display memory */
  136.                  #define GRD_192K          0x0060           /* 192K -- some 640x480 EGA-s */
  137.                  #define GRD_M_NOTSPEC     0x0000           /* memory amount not specified */
  138.  
  139.           An  old style driver has the 'GRD_NEW_DRIVER' bit cleared. It can
  140.           work  with  previous versions  of GO32.  Of  course for  16 color
  141.           support  the application has to be linked with the LIBGRX library
  142.           instead of the original 256 color library.
  143.  
  144.           The following additional old format graphics drivers are supplied
  145.           with the LIBGRX graphics library:
  146.  
  147.                EGA16.GRD 16 color EGA driver (640x350x16 max. resolution)
  148.                VGA16.GRD 16  color  standard  VGA  driver  (640x480x16 max.
  149.                          resolution)
  150.                TSENG4KN.GRD   same  as  DJGPP's  Tseng  ET 4000  256  color
  151.                               driver, but with added support for the 100x40
  152.                               text mode. (max: 1024x768x256)
  153.                TSENG416.GRD   Tseng   ET  4000   16  color   driver.  (max:
  154.                               1024x768x16)
  155.                TRID89N.GRD    Trident  8900 256  color driver.  This driver
  156.                               has  an updated paging routine which seems to
  157.                               fix some  previous  problems on  boards  with
  158.                               recent enough chipsets. (max: 1024x768x256)
  159.                TRID8916.GRD:  Trident   8900   16   color    driver   (max:
  160.                               1024x768x16)
  161.  
  162.  
  163.           New driver format
  164.  
  165.           The disadvantage of the old driver  format is that the number  of
  166.           colors is  not programmable.  The new driver  format solves  this
  167.           problem and it also gives the application  program a way to query
  168.           the  driver for a list of  the supported text and graphics modes.
  169.           For this the driver header was extended as follows:
  170.  
  171.           struct new_driver_header {
  172.                      u_short      mode_set_routine_offset;
  173.                      u_short      paging_routine_offset;
  174.                      u_short      driver_mode_flag;                 /* flag word, see bits below */
  175.                      u_short      default_text_width;
  176.                      u_short      default_text_height;
  177.                      u_short      default_graphics_width;
  178.                      u_short      default_graphics_height;
  179.  
  180.  
  181.  
  182.  
  183.  
  184.                      u_short      default_color_number;             /* NEW, may be set from environment */
  185.                      u_short      init_routine_offset;              /* NEW, call once after drvr loaded */
  186.                      u_short      text_mode_table_offset;           /* NEW, table of supported text modes */
  187.                      u_short      graphics_mode_table_offset;       /* NEW, table of supported graphics modes */
  188.                  };
  189.  
  190.           'text_mode_table_offset'  points  to  a  table  with  entries  as
  191.           follows:
  192.  
  193.           struct text_mode_entry {
  194.                      u_short      columns;
  195.                      u_short      rows;
  196.                      u_short      number_of_colors;                 /* in text mode it is mainly here to make
  197.                                                                        GCC happy with the alignments */
  198.                      u_char       BIOS_mode;                        /* BIOS mode number. Mode not available on
  199.                                                                        the current card if this field is 0xff. */
  200.                      u_char       special;                          /* if non zero then the driver does some
  201.                                                                        special hacks to set it up (like
  202.                                                                        the 50 row mode on a standard VGA) */
  203.                  };
  204.  
  205.           The end  of the  table is  marked by  an all  0 entry. The  table
  206.           entries   are    sorted   by   increasing    size.   The    field
  207.           'graphics_mode_table_offset' points  to a  table with  entries as
  208.           follows:
  209.  
  210.  
  211.  
  212.  
  213.  
  214.                  struct graphics_mode_entry {
  215.                      u_short      width;
  216.                      u_short      height;
  217.                      u_short      number_of_colors;
  218.                      u_char       BIOS_mode;                        /* BIOS mode number. Mode not available on
  219.                                                                        the current card if this field is 0xff.
  220.                                                                        (This may happen for example if the card
  221.                                                                        is not fully populated with RAM) */
  222.                      u_char       special;                          /* if non zero then the driver does some
  223.                                                                        special hacks to set it up (like
  224.                                                                        setting up the 32768 color mode on
  225.                                                                        some ET4000 cards) */
  226.                  };
  227.  
  228.           The end of the  table is marked by an  all 0 entry. The  table is
  229.           sorted by increasing color number and within the same color modes
  230.           by increasing size.
  231.  
  232.           If  the  driver is  of  the new  type  then it  also  supports an
  233.           initialization routine. This is  called once after the driver  is
  234.           loaded.  The initialization  routine can  do one  or more  of the
  235.           following:
  236.  
  237.             (1)     Check whether the video card is of the expected type
  238.  
  239.             (2)     Determine the amount of video memory on board.
  240.  
  241.             (3)     Determine which  of the modes in the  text and graphics
  242.                     mode tables  are actually  available (due to  video RAM
  243.                     and possibly DAC [32768 colors!!] limitations) and mark
  244.                     the unavailable entries in the tables.
  245.  
  246.           To use  the new format  drivers a recent  version of  GO32 (1.06,
  247.           after  the middle of  April 1992) has  to be used.  Such versions
  248.           should  recognize the  "nc  <number>" option  field  in the  GO32
  249.           environment variable which specifies the default number of colors
  250.           for the driver.
  251.  
  252.           The  following new  format drivers  have been  included with  the
  253.           LIBGRX library (new drivers have the ".GRN" extension):
  254.  
  255.                STDEGA.GRN     standard EGA 16 color driver
  256.                STDVGA.GRN     standard VGA 16 and 256 color driver
  257.                ET4000.GRN     Tseng ET 4000 16 and 256 color driver
  258.                TR8900.GRN     Trident 8900 16 and 256 color driver
  259.  
  260.  
  261.           Creating a driver for an unsupported board
  262.  
  263.           You can only use EGA or VGA boards in 16 or 256 color  modes with
  264.           the  graphics library. In the  near future there  will be support
  265.           for 32768 color VGA modes and Hercules boards as well. SUPPORT IS
  266.           NOT PLANNED FOR: BOARDS  WITH ON-BOARD GRAPHICS PROCESSORS (TIGA,
  267.           8514A, etc...) To create  a driver for an unsupported EGA  or VGA
  268.  
  269.  
  270.  
  271.  
  272.  
  273.           board you will need the followings:
  274.  
  275.             (1)     An assembler (TASM  or MASM), a linker  (TLINK or LINK)
  276.                     and  a utility to convert .EXE files to the .COM format
  277.                     (EXE2BIN).  See  also the  'makefile' in  the 'drivers'
  278.                     sub-directory.
  279.             (2)     A  documentation of the  board containing the supported
  280.                     BIOS mode numbers and resolutions. 
  281.             (3)     If the driver needs to support modes which use a memory
  282.                     map bigger than 64K then you also  need a piece of code
  283.                     which  does page  switching  on your  board. (Any  mode
  284.                     above 800x600  in 16  colors or  320x200 in  256 colors
  285.                     DOES USE paging.) Possible sources:
  286.                    -     a working, tested 256 color original  DJGPP driver
  287.                          (if you  just  want  to  convert  it  to  the  new
  288.                          format).
  289.                    -     VGAKIT.ZIP (available from various  archive sites,
  290.                          like wuarchive, simtel, etc...)
  291.                    -     various books on the subject.
  292.  
  293.           It  is  best to  start  with the  source of  a  driver supporting
  294.           similar resolutions as your board. Use  the proper format driver,
  295.           i.e. if you  want a new format driver start  with a new original,
  296.           etc...  Typically   the  driver   sources  are   relatively  well
  297.           commented. What you need to do is:
  298.  
  299.             (1)     possibly change  the  option word  at the  head of  the
  300.                     driver  to indicate  the number  of colors  (old format
  301.                     only),  the  amount  of  memory on  board,  the  memory
  302.                     mapping capabilities of the board. 
  303.             (2)     change the mode  setting code  to use  the proper  BIOS
  304.                     mode  numbers.  In the  old  format  drivers these  are
  305.                     somewhat  scattered  throughout the  code,  in  the new
  306.                     format drivers you need to edit a few tables only.
  307.             (3)     Replace the  paging routine  with the one  suitable for
  308.                     your   board.  If   your  driver   supports  16   color
  309.                     resolutions beyond  800x600 then you have  to make sure
  310.                     that  upon exit  from the  paging routine  the graphics
  311.                     controller port's (0x3ce) index register is reset to 8.
  312.                     (See the paging routine in "TR8900.ASM".) If the paging
  313.                     mechanism does  not use  any register accessed  through
  314.                     the graphics  controller port,  then you don't  need to
  315.                     worry about this.
  316.